<%@page import="cn.edu.pzhu.javaweb.pojo.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="menu.jsp"/>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>文件列表</title>
<style>
    table {
        width: 100%;
        border-collapse: collapse; /* 合并边框，避免表格间隙 */
        margin: 10px 0;
    }
    th, td {
        border: 1px solid #ccc;
        padding: 8px 12px; /* 统一单元格内边距 */
        text-align: center;
    }
    th {
        background-color: #f5f5f5;
    }
    .title {
        text-align: center;
        margin: 15px 0;
    }
    /* 分页样式 */
    .pagination {
        margin: 15px 0;
        text-align: center;
        padding: 10px;
    }
    .pagination a {
        display: inline-block;
        padding: 5px 10px;
        margin: 0 3px;
        border: 1px solid #ccc;
        text-decoration: none;
        color: #333;
    }
    .pagination a:hover {
        background-color: #f0f0f0;
    }
    .pagination .current {
        display: inline-block;
        padding: 5px 10px;
        margin: 0 3px;
        border: 1px solid #007bff;
        background-color: #007bff;
        color: white;
    }
    .pagination form {
        display: inline;
        margin-left: 15px;
    }
    .pagination form input {
        margin: 0 5px;
    }
    /* 底部空白样式 */
    .bottom-space {
        margin-bottom: 40px; /* 可根据需要调整空白高度 */
    }
</style>
</head>
<body>
    <h1 class="title">文件列表</h1>
    <table>
        <tr>
            <th>序号</th>
            <th>分享用户</th>
            <th>文件名称</th>
            <th>文件类型</th>
            <th>文件下载</th>
            <th>公开时间</th>
            <th>推荐指数</th>
            <th>文件描述</th>
            <th>操作</th>
        </tr>
        
        <c:forEach items="${fileList}" var="file" varStatus="status">
            <tr>
                <td>${status.count}</td>
                <td>${file.username}</td>
                <td>${file.filename}</td>
                <td>${file.classification}</td>
                <td><a href="${file.filepath}">下载</a></td>
                <td>${file.releasedate}</td>
                <td>${file.rating}</td>
                <td>${file.description}</td>
                <td>
                    <a href="">删除</a>
                    <a href="">编辑</a>
                </td>
            </tr>
        </c:forEach>
    </table>
    <div class="pagination">
        <c:if test="${sessionScope.page > 1}">
            <a href="showfiles?page=${sessionScope.page - 1}&num=${sessionScope.num}">上一页</a>
        </c:if>

        <c:forEach var="i" begin="1" end="${sessionScope.totalpage}">
            <c:choose>
                <c:when test="${i == sessionScope.page}">
                    <span class="current">${i}</span>
                </c:when>
                <c:otherwise>
                    <a href="showfiles?page=${i}&num=${sessionScope.num}">${i}</a>
                </c:otherwise>
            </c:choose>
        </c:forEach>

        <c:if test="${sessionScope.page < sessionScope.totalpage}">
            <a href="showfiles?page=${sessionScope.page + 1}&num=${sessionScope.num}">下一页</a>
        </c:if>

        <form action="showfiles" method="get">
            <input type="hidden" name="page" value="${sessionScope.page}">
            每页显示:
            <input type="text" name="num" value="${sessionScope.num}" size="3">
            条
            <input type="submit" value="确定">
        </form>
    </div>

    <!-- 底部空白区域 -->
    <div class="bottom-space"></div>
</body>
</html>